package com.flower.config;

import com.flower.gateway.CloudSecurityProperties;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import java.util.concurrent.*;

/**
 * @ClassName ConfigBean
 * @Description TODO
 * @Author 吃麻椒的花酱
 * @Date 2022/4/6 12:00
 * @Version 1.0
 */
@EnableConfigurationProperties({AliyunOss.class, CloudSecurityProperties.class})
@Configuration
public class ConfigBean {
    /**
     * @author 吃麻椒的花酱
     * @date 2022/4/15 17:51
     * @Description 自定义线程池
     * @param
     * @return java.util.concurrent.ThreadPoolExecutor
     */
    @Bean(name = "executer")
    public ThreadPoolExecutor threadPoolExecutor() {
        RejectedExecutionHandler rejected = new ThreadPoolExecutor.DiscardPolicy();
        return new ThreadPoolExecutor(2,4, 5,
                TimeUnit.SECONDS, new ArrayBlockingQueue(10,true),
                Executors.defaultThreadFactory(), rejected);
    }

}
